package com.xzlf.config;

import com.xzlf.domain.JobTask;
import com.xzlf.service.JobTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Configuration
public class JobTaskConfig /*implements CommandLineRunner*/ {



    @Autowired
    private JobTaskService jobTaskService;

    @Bean
    public Map<String, JobTask> jobTaskMap(){
        Map<String, JobTask> jobTaskMap = new HashMap();
        List<JobTask> list = jobTaskService.list();
        for (JobTask jobTask : list) {
            jobTaskMap.put(jobTask.getJobName(), jobTask);
        }
        return jobTaskMap;
    }

//    @Override
//    public void run(String... args) throws Exception {
//        List<JobTask> list = jobTaskService.list();
//        for (JobTask jobTask : list) {
//            jobTaskMap.put(jobTask.getJobName(), jobTask);
//        }
//    }





    /*@PostConstruct
    public void init(){
        List<JobTask> list = jobTaskService.list();
        for (JobTask jobTask : list) {
            JobTaskConfig.jobTaskMap.put(jobTask.getJobName(), jobTask);
        }
    }*/

}
